﻿using System;
using System.Collections;
using System.Collections.Generic;

public class Singleton<T> : System.IDisposable where T : new()
{
    private static T instance;
    public static T Instance
    {
        get
        {
            lock (instance)
            {
                if (instance == null)
                {
                    instance = new T();
                }
                return instance;
            }        
        }
    }

    public virtual void Dispose()
    {
        // 内存处理的善后工作
    }
}

